﻿#ifndef STASHMANAGEMODELOBJECT_H
#define STASHMANAGEMODELOBJECT_H
#include<QObject>
#include<QPointer>
#include<QSharedPointer>
#include"XQSettingsInfo.h"
#include"XQMySql.hpp"
#include"XQMail.h"
#include"XQThreadQueuePool.h"
#include"XQUserData.h"
#include"XQUserInfo.h"
class XQMySql;
class XQSettingsInfo;
class StashManageModelObject
{
public:
	StashManageModelObject();
	StashManageModelObject(XQMySql* mysql, XQMail* mail, XQSettingsInfo* settings, XQThreadQueuePool* pool);
	virtual ~StashManageModelObject();
public:
	XQUserData userData();
	UserState userState();
	XQMail* mail()const;
	XQMySql* mysql()const;
	XQSettingsInfo* settings()const;
	XQThreadQueuePool* pool()const;
	XQUserInfo* userInfo()const;
public:
	//连接数据库进行登录
	bool connectionMySql(XQDatabaseConnectionModel data);
	//添加一个多线程任务
	XQThreadTask* addMySqlThreadTask(XQThreadTask* task);
	XQThreadTask* addMySqlThreadTask(std::function<void(XQThreadTask*)>&& task);
	XQThreadTask* addMySqlThreadTask(std::function<void()>&& task);
public:
	bool sendVerifyMail(const QString& email, const QString& mail_title, qint64 verify);
public:
	void setUserData(const XQUserData& userData);
	void setUserState(UserState state);
	void setMySql(XQMySql* mysql);
	void setMail(XQMail* mail);
	void setSettings(XQSettingsInfo* settings);
	void setUserInfo(XQUserInfo* info);
	///*
	//* @brief 读取配置文件.
	//* @param file:配置文件
	//*/
	//void readSettings(const QString& file);
public:

private:
	//XQMySql* m_mysql = nullptr;
	//XQSettingsInfo* m_settings=nullptr;
	QPointer<XQMail>m_mail;
	QPointer<XQMySql>m_mysql;
	QPointer<XQSettingsInfo> m_settings;
	QPointer<XQThreadQueuePool>m_pool;
	QPointer<XQUserInfo> m_userInfo;
	//QSharedPointer<UserState> m_userState;
};
#endif // !StashManageModelObject_h
